@extends('admin.layout.layout', ['row' => @$page])

@section('contain')


    <div class="portlet">
        <div class="portlet-title">
            <div class="caption">
                <x-portlet-breadcrumb :page="$page"></x-portlet-breadcrumb>
            </div>
            <div class="actions"></div>
        </div>

        <form action="/{{ request()->path() }}/../" method="post" onsubmit="return checkVal(this)" class="precut-form t-right">
            @csrf
            @method('PUT')
            <input type="text" name="_previous_" value="{{ request()->header('referer') }}" hidden>


            <table class="table s3">
                <tbody>
                <tr>
                    <td class="tth">{{ ts('AZFS') }}</td>
                    <td class="ttd">
                        <select name="install_type" id="" class="form-control" onchange="ins_change(this.value)">
                            <option value="0">{{ ts('ptaz') }}</option>
                            @if(session('admin.user_type') == 2)
                                @foreach(getDPDs(session('admin.id')) as $v)
                                    <option value="{{ @$v->id }}" {{ $data->pre_id == @$v->id ? 'selected' : '' }}>{{ @$v->precut_id }}</option>
                                @endforeach
                            @endif
                        </select>
                    </td>
                    <td colspan="4" class="text-danger">{{ ts('wcit3') }}</td>
                </tr>
                <tr>
                    <td colspan="6" class="tst">{{ ts('CUSTOMER') }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('CUSTOMERNAME') }}</td>
                    <td class="ttd">
                        <input type="text" name="first_name" value="{{ $data->first_name ?: old('first_name') }}" class="form-control">
                    </td>
                    <td class="tth">{{ ts('phonenumber') }}</td>
                    <td class="ttd">
                        <div class=" input-group custom-control-inline">
                            <div class="input-group-prepend">
                                <select name="extension" class="form-control">
                                    @foreach(\App\Models\PhoneExtension::get(['id', 'phone_ext']) as $v)
                                        <option value="{{ $v->phone_ext }}" {{ ($data->extension == $v->phone_ext || old('phone_number')==$v->phone_ext ) ? 'selected' : '' }}>{{ $v->phone_ext }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <input type="number" name="phone_number" value="{{ $data->phone_number ?: old('phone_number') }}" class="form-control">
                        </div>
                    </td>
                    <td class="tth">{{ ts('email') }}</td>
                    <td class="ttd">
                        <input type="email" name="email_address" value="{{ $data->email_address ?: old('email_address') }}" class="form-control">
                    </td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('region') }}</td>
                    <td>
                        <select name="region_id" id="" class="form-control region_json" data-value="{{ $data->region_id ?: old('region_id') }}">
                            <option value="">{{ ts('select') }}</option>
                            <option value="{{ $data->region_id }}" selected>{{ ts('region_master.'.$data->region_id) }}</option>
                        </select>
                    </td>
                    <td class="tth">{{ ts('province') }}</td>
                    <td>
                        <select name="province_id" id="" class="form-control province_json" data-value="{{ $data->province_id ?: old('province_id') }}">
                            <option value="">{{ ts('select') }}</option>
                            <option value="{{ $data->province_id }}" selected>{{ ts('province_master.'.$data->province_id) }}</option>
                        </select>
                    </td>
                    <td class="tth">{{ ts('city') }}</td>
                    <td>
                        <select name="city" id="" class="form-control city_json" data-value="{{ $data->city ?: old('city') }}">
                            <option value="">{{ ts('select') }}</option>
                            <option value="{{ $data->city }}" selected>{{ ts('cities.'.$data->city) }}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('addresss') }}</td>
                    <td colspan="3">
                        <input type="text" name="address" value="{{ $data->address ?: old('address') }}" class="form-control">
                    </td>
                    <td class="tth">{{ ts('zip') }}</td>
                    <td>
                        <input type="text" name="addresss" value="{{ $data->zip ?: old('zip') }}" class="form-control">
                    </td>
                </tr>
                <tr>
                    <td colspan="6" class="tst">{{ ts('VEHICLEINFORMATION') }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('year') }}</td>
                    <td>
                        <select name="year_id" id="" class="form-control make_json_year" data-value="{{ $data->year_id ?: old('year_id') }}">
                            <option value="">{{ ts('select') }}</option>
                            <option value="{{ $data->year_id }}" selected>{{ $data->year_id }}</option>
                        </select>
                    </td>
                    <td class="tth">{{ ts('make') }}</td>
                    <td>
                        <select name="make_id" id="" class="form-control make_json_make" data-value="{{ $data->make_id ?: old('make_id') }}">
                            <option value="">{{ ts('select') }}</option>
                            <option value="{{ $data->make_id }}" selected>{{ ts('make_master.'.$data->make_id) }}</option>
                        </select>
                    </td>
                    <td class="tth">{{ ts('model') }}</td>
                    <td>
                        <input type="text" name="model_id" value="{{ $data->model_id ?: old('model_id') }}" class="form-control" >
                    </td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('licenseplate') }}</td>
                    <td>
                        <input type="text" name="license_plate" value="{{ $data->license_plate ?: old('license_plate') }}" class="form-control" >
                    </td>
                    <td class="tth">{{ ts('vinnumber') }}</td>
                    <td colspan="3">
                        <input type="text" name="vin_number" value="{{ $data->vin_number ?: old('vin_number') }}" class="form-control" >
                    </td>
                </tr>
                <tr>
                    <td colspan="6" class="tst">{{ ts('INSTALLATIONINFORMATION') }}</td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('distributor') }}</td>
                    <td>
                        <input type="text" class="form-control sdjc" disabled name="sdjc" value="{{ getDJc($data->user_id) }}">
                    </td>
                    <td class="tth">{{ ts('qudao') }}</td>
                    <td>
                        <div class="input-group">
                            <input type="number" value="{{ $data->user_id }}" name="user_id" hidden>
                            <select class="form-control roll_user_id" name="user_id" disabled>
                                <option value="{{ $data->user_id }}">{{ getJc($data->user_id) }}</option>
                            </select>
                            @empty($data->pre_id)
                                <div class="input-group-prepend">
                                    <span class="btn btn-primary"  data-toggle="modal" data-target="#changeWarrantyUser">{{ ts('XG') }}</span>
                                </div>
                            @endif
                        </div>
                    </td>{{--
                    @if(session('admin.user_type')==1)
                        <td class="tth">{{ ts('distributor') }}</td>
                        <td>
                            <select class="form-control roll_user_id" name="sdid">
                                @foreach(getDistributors() as $v)
                                    <option value="{{ $v->id }}">{{ $v->abbr ?: $v->company_name }}</option>
                                @endforeach
                            </select>
                        </td>
                        <td class="tth">{{ ts('qudao') }}</td>
                        <td>
                            <select class="form-control" name="user_id"></select>
                        </td>
                    @else
                        <td class="tth">{{ ts('distributor') }}</td>
                        <td>
                            <input type="text" class="form-control sdjc" disabled name="sdjc" value="{{ getJc(session('admin.id')) }}">
                        </td>
                        <td class="tth">{{ ts('qudao') }}</td>
                        <td>
                            <select class="form-control roll_user_id" name="user_id">
                                @foreach(getDDs(session('admin.id')) as $v)
                                    <option value="{{ $v->id }}" {{ ($data->user_id==$v->id || old('user_id')==$v->id) ? 'selected' : ''  }}>{{ $v->abbr ?: $v->company_name }}</option>
                                @endforeach
                            </select>
                        </td>
                    @endif--}}
                    <td colspan="2" class="text-danger">
                        @empty($data->pre_id)
                            {{ ts('wcit') }}
                        @else
                            {{ ts('wcit2') }}
                        @endif
                    </td>
                </tr>
                <tr>
                    <td class="tth">{{ ts('INSTALLERNAME') }}</td>
                    <td>
                        <input type="text" name="installer_name" value="{{ $data->installer_name ?: old('installer_name') }}" class="form-control" >
                    </td>
                    <td class="tth">{{ ts('INSTALLATIONDATE') }}</td>
                    <td>
                        <div class="input-group">
                            <input type="text" name="installation_date" value="{{ $data->installation_date ?: old('installation_date') }}" class="form-control flatpickr-ymdhis" data-max="{{ date('Y-m-d H:i:s') }}">
                            <div class="input-group-prepend">
                                <span class="btn btn-primary fkr-clear"><i class="fa fa-times"></i></span>
                            </div>
                        </div>
                    </td>
                    <td class="tth">{{ ts('INSTALLERPRICE') }}</td>
                    <td>
                        <input type="text" name="installation_price" value="{{ $data->installation_price ?: old('installation_price') }}" class="form-control" >
                    </td>
                </tr>
                <tr>
                    <td colspan="6" class="tst">{{ ts('INSTALLATIONPICTURE') }}</td>
                </tr>
                <tr>
                    <td colspan="6" class="ttt">
                        <x-warranty-image-upload :warranty="$data"></x-warranty-image-upload>
                        {{--@include('admin.components.aztp-tb')--}}
                    </td>
                </tr>
                <tr>
                    <td colspan="6" class="tst">{{ ts('VEHICLECOVERAGE') }}</td>
                </tr>
                <tr>
                    <td colspan="6" class="ttt">
                        <div class="container-fluid">
                            {{--warranty_coverage--}}
                            @include('admin.subview.warranty_coverage', ['coverages' => @$coverages, 'is_precut'=>1])
                        </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="6" class="tst">{{ ts('BCSM') }}</td>
                </tr>
                <tr>
                    <td colspan="6" height="auto">
                        <textarea name="additional_comments"  height="auto" rows="6" id="" class="form-control">{{ @$data->additional_comments ?: old('additional_comments') }}</textarea>
                    </td>
                </tr>
                </tbody>
            </table>

            <div class="mt-4">
                <button class="btn btn-primary">{{ ts('store') }}</button>
            </div>
        </form>
    </div>

@endsection